<?php use_stylesheets_for_form($form) ?>
<?php use_javascripts_for_form($form) ?>

<form id="formB" action="<?php echo url_for('order/'.($form->getObject()->isNew() ? 'create' : 'update').(!$form->getObject()->isNew() ? '?idOrder='.$form->getObject()->getIdorder() : '')) ?>" method="post" <?php $form->isMultipart() and print 'enctype="multipart/form-data" ' ?>>
<?php if (!$form->getObject()->isNew()): ?>
<input type="hidden" name="sf_method" value="put" />
<?php endif; ?>
  <table id="order_form">
    <tbody>
      <?php 
      //echo $form 

      //straight
         ?>
      <tr>
        <td>
          <?php
          echo $form['orderName']->renderRow();
          ?>
        </td>
      </tr>
      <tr>
        <td>
          <?php
          echo $form['textCategoryId']->renderRow();
          ?>
        </td>
      </tr>
      
      <tr>
        <th>Media</th>
        <td>
          <table>
            <tr>
              <th><?php echo $form['is_website']->renderLabel(); ?></th>
              <td>
                <?php
                echo $form['is_website']->render();
                ?>
              </td>
              <th><?php echo $form['is_print']->renderLabel(); ?></th>
              <td>
                <?php
                echo $form['is_print']->render();
                ?>
              </td>
            </tr>
            <tr>
              <th><?php echo $form['is_newsletter']->renderLabel(); ?></th>
              <td>
                <?php
                echo $form['is_newsletter']->render();
                ?>
              </td>
              <th><?php echo $form['is_poster']->renderLabel(); ?></th>
              <td>
                <?php
                echo $form['is_poster']->render();
                ?>
              </td>
            </tr>
            <tr>
              <th><?php echo $form['is_blog']->renderLabel(); ?></th>
              <td>
                <?php
                echo $form['is_blog']->render();
                ?>
              </td>

              <th><?php echo $form['Other text media']->renderLabel(); ?></th>
              <td>
                <?php
                echo $form['Other text media']['otherText']->render();
                echo $form['Other text media']['name']->render();
                ?>
              </td>

            </tr>
          </table>
        </td>        
      </tr>
      <tr>
        <th><?php echo $form['targetGroupId']->renderLabel(); ?></th>
        <td>
          <?php
          echo $form['targetGroupId']->render();
          ?>
        </td>
      </tr>
      
      
       <tr>
        <th></th>
        <td>
          <table id="targetGroup">
            <tr>
              <th><?php echo $form['is_existing_custormer']->renderLabel(); ?></th>
              <td>
                <?php
                echo $form['is_existing_custormer']->render();
                ?>
              </td>
              <th><?php echo $form['is_new_customer']->renderLabel(); ?></th>
              <td>
                <?php
                echo $form['is_new_customer']->render();
                ?>
              </td>
            </tr>
            <tr>
              <th><?php echo $form['is_men']->renderLabel(); ?></th>
              <td>
                <?php
                echo $form['is_men']->render();
                ?>
              </td>
              <th><?php echo $form['is_women']->renderLabel(); ?></th>
              <td>
                <?php
                echo $form['is_women']->render();
                ?>
              </td>
            </tr>
          </table>
        </td>
       </tr>
      
      
     
      <tr>
        <td>
          <?php
          echo $form['formalStyleId']->renderRow();
          ?>
        </td>
      </tr>
      <tr>
        <th></th>
        <td>
          <table>
            <tr>
              <td> 
                <?php
                $formalStyle = $form->getWidget('formalStyleId')->getChoices();
                echo $formalStyle[1];
                ?>
              </td>
              <td><?php echo $formalStyle[2]; ?></td>
              <td><?php echo $formalStyle[3]; ?></td>
            </tr>  
          </table>
        </td>
      </tr>
      <tr>
        <td>
          <?php
          echo $form['personStyleId']->renderRow();
          ?>
        </td>
      </tr>
      <tr>
        <th></th>
        <td>
          <table id="personStyleId">
            <tr>
              <td id="personStyle0"> 
                <?php
                $personStyle = $form->getWidget('personStyleId')->getChoices();
                echo $personStyle[1];
                ?>
              </td>
              <td id="personStyle1"><?php echo $personStyle[2]; ?></td>
              <td id="personStyle2"><?php echo $personStyle[3]; ?></td>
            </tr>  
          </table>
        </td>
      </tr>
      <tr>
        <td>
          <?php
          echo $form['emotionStyleId']->renderRow();
          ?>
        </td>
      </tr>
      <tr>
        <th></th>
        <td>
          <table>
            <tr>
              <td> 
                <?php
                $emotionStyle = $form->getWidget('emotionStyleId')->getChoices();
                echo $emotionStyle[1];
                ?>
              </td>
              <td><?php echo $emotionStyle[2]; ?></td>
              <td><?php echo $emotionStyle[3]; ?></td>
            </tr>  
          </table>
        </td>
      </tr>
      <tr>
        <td>
          <?php
          echo $form['formulateId']->renderRow();
          ?>
        </td>
      </tr>
      <tr>
        <th></th>
        <td>
          <table>
            <tr>
              <td> 
                <?php
                $formulateStyle = $form->getWidget('formulateId')->getChoices();
                echo $formulateStyle[1];
                ?>
              </td>
              <td><?php echo $formulateStyle[2]; ?></td>
              <td><?php echo $formulateStyle[3]; ?></td>
              <td><?php echo $formulateStyle[4]; ?></td>
              <td><?php echo $formulateStyle[5]; ?></td>
            </tr>  
          </table>
        </td>
      </tr>
<!--      <tr>
        <td>
          <?php
            //echo $form['urlImageStructure']->renderRow();
          ?>
        </td>
      </tr>-->
      <tr>
        <td>
          <?php
          echo $form['Free text']->renderRow();
          ?>
        </td>
      </tr>
      <tr>
        <td id="standardOrder">
          <?php
          echo $form['is_standard']->renderRow();
          ?>
        </td>
      </tr>
      <tr id="edOptions">
        <th><?php echo $form['Edition options']->renderLabel(); ?></th>
        <td>
          <table>
            <tbody>
              <tr id="technicalTerms">
                <?php
                echo $form['Edition options']['is_technical_terms']->renderRow();
                ?>
              </tr>
              <tr id="foreignWord">
                <?php
                echo $form['Edition options']['is_foraign_word']->renderRow();
                ?>
              </tr>
              <tr id="superlative">
                <?php
                echo $form['Edition options']['is_superlative']->renderRow();
                ?>
              </tr>
              <tr id="oldLanguage">
                <?php
                echo $form['Edition options']['is_old_language']->renderRow();
                ?>
              </tr>
              <tr id="startSentence">
                <?php
                echo $form['Edition options']['is_start_of_sentence']->renderRow();
                ?>
              </tr>
              <tr>
                <td>
                  <table>
                    <tbody>
                      <tr id="isOwnChoice">
                        <?php
                        echo $form['Edition options']['Own choice']['is_own_choice']->renderRow();
                        ?>
                      </tr>
                      <tr id="ownChoiceText">
                        <?php
                        echo $form['Edition options']['Own choice']['text']->renderRow();
                        ?>
                      </tr>
                    </tbody>
                  </table>
                </td>
              </tr>
              <tr id="moreTextEditions">
                <?php
                echo $form['Edition options']['moreText']->renderRow();
                ?>
              </tr>
            </tbody>
          </table>
          <?php
          //old version
//          echo $form['Edition options']->render();
          ?>
        </td>
      </tr>

      
      <?php
  
      
      
      if ($form->isCSRFProtected())
      {
          echo $form['_csrf_token']->render();
      }

      
      //iterativ  
//      $i = 0;
//      
//      if ($form->isCSRFProtected())
//      {
//          echo $form['_csrf_token']->render();
//      }
//      while ($i < $form->getFormFieldSchema()->count())
//      {
//         
//          
//        if($form->getFormFieldSchema()->current()->getName() != 'editionOptionsId')
//        {
//         if($form->getFormFieldSchema()->current()->getName() != 'freeTextId')
//        { 
//          if($form->getFormFieldSchema()->current()->getName() != 'otherTextMediumId')
//          {
//             if($form->getFormFieldSchema()->current()->getName() != '_csrf_token') 
//             {
//              if($form->getFormFieldSchema()->current()->getName() != 'idOrder')
//              {
//                echo $form->getFormFieldSchema()->current()->renderRow(); 
//              }
//             }
//          } 
//          }
//        }
//        $form->getFormFieldSchema()->next();
//        $i++;     
//      }
//      
//      foreach($form->getEmbeddedForms() as $formName => $embeddedForm)
//      { 
//        echo $embeddedForm; 
//      }     
      
      ?>
    </tbody>
    <tfoot>
      <tr>
        <td colspan="2">
          &nbsp;<a id="back2List" href="<?php echo url_for('order/index') ?>">Back to list</a>
          <?php if (!$form->getObject()->isNew()): ?>
            &nbsp;<?php echo link_to('Delete', 'order/delete?idOrder='.$form->getObject()->getIdorder(), array('method' => 'delete', 'confirm' => 'Are you sure?')) ?>
          <?php endif; ?>
          <input id="saveButton" type="submit" value="Save" />
        </td>
      </tr>
    </tfoot>
  </table>
</form>
